package org.eclipse.epsilon.emc.rdbms.core.persistancemechanism;

import java.sql.Connection;
public abstract class PersistanceMechanism
{
	 
	   protected  Connection connection; 

	   /**
		* This opens a connection to the perisstance mechanism
		* @return the result of getConnection which is a connection to the persistance object either file or database.
		*/				   
	    public Connection open()   
		   {
					return getConnection();
		   }
	    
	    /**
		* This is the abstract method for getConnection and returns the connection to either the database or file.
		*/
	    abstract Connection getConnection();
	 
	    /**
		* This closed a connection to the persistance mechanism
		*/
	    public  void close()
		{
			     try
			     {
			       if(connection!=null)
			       { 
			          connection.close();
			          connection=null;
			       }
			     }
			     catch(Exception e)
			     {
			          e.printStackTrace();
			     }
		}
		
}



